<template>
	<view class="single_list">
		<div>
			<navitop>
				<i class="iconfont" slot="left-slot" @click="outlot">&#xe667;</i>
				<span slot="center-slot"><h4>活动列表</h4></span>
				<i  slot="right-slot" >
					<i class="iconfont icon-jiahao" style="font-size: 25px;padding-left: 15px;" @click="searAlert"></i>
				</i>
			</navitop> 
		</div>
		<div class='single_width' :style="'margin-top:' + nv_height">
			<scroll-view class="staff_b" scroll-y="true" @scrolltolower="button">
				<div class='single_list_bg' v-for="(item,index) in runDataSorce" @click="open(item.id)">
					<div class='single_that'>
						<div>活动名称:</div>
						<div>活动状态:</div>
						<div>活动类型:</div>
						<div>活动负责人:</div>
					</div>
					<div class='single_that'>
						<div>{{item.activityTitle}}</div>
						<div>{{item.activityState}}</div>
						<div>{{item.activityType}}</div>
						<div>{{item.activityOwnerName}}</div>
					</div>
				</div>
			</scroll-view>
		</div>
		
		<!-- 详情列表 -->
		<popus ref="alert" >
			<div :style="alertWidth">
				<acitdetals :selid="selid" @closes="closes"></acitdetals>
			</div>
		</popus>
		
		<!-- 活动添加 -->
		<popus ref="active">
			<div :style="alertWidth">
				<activityadd @closeslist="closeslist"></activityadd>
			</div>
		</popus>
		
		<!-- 气泡弹窗 -->
		 <chunLei-popups v-model="value" :popData="data" @tapPopup="tapPopup" :x="345" :y="95" placement="top-end">
		 </chunLei-popups>
	</view>
</template>

<script>
import activityadd from '@/pages/common/index/subpage/activety/activityadd' // 活动添加
import acitdetals from '@/pages/common/index/subpage/activety/activitydetals'	
import popus from '@/uni_modules/uni-popup/components/uni-popup/uni-popup'
import chunLeiPopups from "@/components/chunLei-popups/chunLei-popups";
import navitop from '@/components/common/navi-top'
import {list,pages,city,detail,activ,pageList,getUserInfo} from '@/common/api/job/jobapi.js'
export default {
	components:{
		popus,
		acitdetals,
		navitop,
		chunLeiPopups,
		activityadd
	},
	data(){
		return {
			runDataSorce: [],
			data: [{title:'添加',code:'detialadd',icon:'icon-tianjiaadd143'}],
			alertWidth: '',
			selid:'',
			pages: 1 	,//分页
			nv_height: '',
			value:false,
		}
	},
	mounted() {
		let _this = this;
		// 顶部距离
		this.nv_height = uni.getSystemInfoSync().statusBarHeight + 75 + 'px';
		// 弹窗宽度
		uni.getSystemInfo({
		    success: function (res) {
				_this.alertWidth = 'width:' + res.windowWidth + 'px;'
		    }
		});
		
		this.activitys();
	},
	methods:{
		// 返回
		outlot(){
			uni.navigateBack()
		},
		
		// 获取市场活动
		activitys(uids,page){
			uni.showLoading({
				title: "加载中..."
			})
			activ({current: 1,size: 20}).then((val) => {
				if(val.code == 200){
					uni.hideLoading();
					this.activaty = true;
					if(!val.data.records.length){
						uni.showToast({
							title: '没有更多了',
							icon: 'error'
						}) 
					}
					if(this.runDataSorce){
						for(let i in val.data.records){
							this.runDataSorce.push(val.data.records[i])
						}
					}else{
						this.runDataSorce = val.data.records;
					}
				}
			})
		},
		
		// 添加
		searAlert(){
			  // this.$refs.active.open('right');
			  this.value = true;
			  
			  
		},
		
		tapPopup(val){
			console.log(val)
			this.$refs.active.open('right');
		},
		
		// 关闭添加窗口(活动)
		closeslist(val){
			console.log(val)
			if(val == 1){
				location.reload();
				this.$refs.active.close();
			}else{
				this.$refs.active.close();
			}
		},
		
		open(val) {
			this.selid = val;
		     this.$refs.alert.open('right');
		},
		
		closes(val){
			if(val == 1){
				this.$refs.alert.close();
				location.reload();
			}else{
				this.$refs.alert.close();
			}
		}
	}
}
</script>

<style scoped lang="scss">

</style>
